<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 500px;
            height: 300px;
            margin: 100px;
            transform-style: preserve-3d;
            /* 透视 */
            perspective: 100000px;
            position: relative;
            transition: all 1s ease;
        }
        .box img{
           /* transition: all 1s ease; */
           position: absolute;
           top: 0;
           left: 0;
           width: 500px;
           height: 300px;
        }
        .box img:nth-child(1){
            transform: translateZ(150px);
        }
        .box img:nth-child(2){
           transform: rotateX(90deg) translateZ(150px);
        }
        .box img:nth-child(4){
            transform: rotateX(-90deg) translateZ(150px);
        }
        .box img:nth-child(3){
            transform: rotateX(180deg) translateZ(150px);
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="./img/my.webp">
        <img src="./img/a.jpg">
        <img src="./img/my.webp">
        <img src="./img/a.jpg">
    </div>
    <button class="next">下一张</button>
    <button class="pre">上一张</button>
</body>
<script src="./js/jquery-1.12.4.js"></script>
<script>
    let box = $(".box");
    var nextButton = $("button.next");
    var preButton = $("button.pre");
    let n = 0;
    nextButton.click(function(){
        n++;
        render();
    })
    preButton.click(function(){
        n--;
        render();
    })
    function render(){
        let deg = n * (-90) ;
        box.css("transform",`rotateX(${deg}deg)`);
    }
</script>
</html>